package com.wangsh.splider.task.pojo;

import com.wangsh.splider.common.pojo.BasePojo;
import com.wangsh.splider.system.pojo.ASysIp;
import com.wangsh.splider.system.pojo.ASysPro;

import java.util.Date;
import java.util.Map;
import java.util.TreeMap;

public class ATaskHistory extends BasePojo<ATaskHistory> {
    private int id;
    private int taskUsersId;
    private int ipId;
    private int sysProId;
    private String os;
    private String broswer;
    private byte status;
    private Date createTime;
    private Date updateTime;
    private Date pubTime;

    /*关联关系  任务概要表 ip地址表 系统配置表 任务*/
    private ATaskUsers aTaskUsers;
    private ASysIp aSysIp;
    private ASysPro aSysPro;

    public ASysPro getaSysPro() {
       return aSysPro;
   }

   public void setaSysPro(ASysPro aSysPro) {
        this.aSysPro = aSysPro;
   }

    public ASysIp getaSysIp() {
        return aSysIp;
    }

    public void setaSysIp(ASysIp aSysIp) {
        this.aSysIp = aSysIp;
    }

    public ATaskUsers getaTaskUsers() {
        return aTaskUsers;
    }

    public void setaTaskUsers(ATaskUsers aTaskUsers) {
        this.aTaskUsers = aTaskUsers;
    }

    /*--字符串表示--*/
    private String statusStr ;
    /* 存储所有状态的容器 */
    private Map<String,String> enumsMap = new TreeMap<String, String>();

    public Map<String, String> getEnumsMap()
    {
        // 根据状态值获取字符串描述
        ATaskHistoryEnum[] aTaskHistoryEnums = ATaskHistoryEnum.values();
        for (int i = 0; i < aTaskHistoryEnums.length; i++)
        {
            ATaskHistoryEnum aTaskHistoryEnum = aTaskHistoryEnums[i];
            String key = aTaskHistoryEnum.toString() ;
            if(key.lastIndexOf("_") != -1)
            {
                key = key.substring(0,key.lastIndexOf("_")) ;
            }
            enumsMap.put(key + "-" + aTaskHistoryEnum.getStatus() + "", aTaskHistoryEnum.getName());
        }
        return enumsMap;
    }

    public String getStatusStr()
    {
        // 根据状态值获取字符串描述
        ATaskHistoryEnum[] aTaskHistoryEnums = ATaskHistoryEnum.values();
        for (int i = 0; i < aTaskHistoryEnums.length; i++)
        {
            ATaskHistoryEnum aTaskHistoryEnum = aTaskHistoryEnums[i];
            if (aTaskHistoryEnum.toString().startsWith("STATUS_"))
            {
                // 表示是状态的标识
                if (aTaskHistoryEnum.getStatus() == this.getStatus())
                {
                    this.statusStr = aTaskHistoryEnum.getName();
                    break;
                }
            }
        }
        return statusStr;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getTaskUsersId() {
        return taskUsersId;
    }

    public void setTaskUsersId(int taskUsersId) {
        this.taskUsersId = taskUsersId;
    }

    public int getIpId() {
        return ipId;
    }

    public void setIpId(int ipId) {
        this.ipId = ipId;
    }

    public int getSysProId() {
        return sysProId;
    }

    public void setSysProId(int sysProId) {
        this.sysProId = sysProId;
    }

    public String getOs() {
        return os;
    }

    public void setOs(String os) {
        this.os = os;
    }

    public String getBroswer() {
        return broswer;
    }

    public void setBroswer(String broswer) {
        this.broswer = broswer;
    }

    public byte getStatus() {
        return status;
    }

    public void setStatus(byte status) {
        this.status = status;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Date getPubTime() {
        return pubTime;
    }

    public void setPubTime(Date pubTime) {
        this.pubTime = pubTime;
    }
}
